<?php
namespace app\manager\controller;
use \think\Controller;
use think\Request;
use think\Session;
class Card extends Controller
{

	public function getIndex()
	{
		$card_list = model('Cards')->getCardLists(input('get.'));
		$this->assign('card_list',$card_list);
		return view('p/card/index');
	}

	public function getAddCard($id)
	{
		$caravan_info = model('Caravans')->getCaravanInfo($id);
		$this->assign('caravan_info',$caravan_info);
		$this->assign('id',$id);
		return view('p/card/add');
	}

	public function getCardInfo($id)
	{
		$card_info = model('Cards')->getCardInfo($id);//halt($card_info);
		$this->assign('card_info',$card_info);
		return view('p/card/card');
	}

	public function postAddCard()
	{
		$post_card_info['card_num'] = model("user/CaravanInfos")->quickRandom(12);
		$post_card_info['contract_num'] = input('post.contract_num');
		$post_card_info['user_phone'] = input('post.user_phone');
		$post_card_info['caravan_id'] = input('post.caravan_id');

		$card = model('Cards')->createCards($post_card_info);
		if ($card) {
			return $this->success('生成卡号成功', '/card/index');
		}
			return $this->error('生成卡号失败');

	}
}